//utf-8
//点击新增按钮 事件跳转至 新增页面
function toAddData(){
	
	var obj={"text":'新建受让赎回交易',"url":contextRootPath+'/transfereeSettle/prepareExecute/toAddTransfereeRedemp'};
	parent.showObj(obj);
}

//修改 事件
function toUpdateData(){
	var v_ids = iframe.iframeObj["table"].getSelectedIds().join(",");
	
	//如果没有选中 数据则
	if(v_ids == ""){
		alert("请选择待修改的数据！");
		return;
	}
	//如果选择多个 择提示
	if(v_ids.indexOf(",") > -1){
		alert("请选择一条数据！");
		return;
	}
	
	var cooperorgCode = iframe.iframeObj["table"].getSelectedObjs("cooperorgCode");
	var contractCode = iframe.iframeObj["table"].getSelectedObjs("contractCode");
	var dealCode = iframe.iframeObj["table"].getSelectedObjs("dealCode");
	var cooperativeAgencyDealStatus = iframe.iframeObj["table"].getSelectedObjs("cooperativeAgencyDealStatus");
	var obj={"text":'修改受让赎回交易',"url":contextRootPath+'/transfereeSettle/prepareExecute/toBackTransfereeDealUpdate?contractCode=' + contractCode + "&dealCode=" + dealCode + "&cooperativeAgencyDealStatus=" + cooperativeAgencyDealStatus + "&cooperorgCode=" + cooperorgCode + "&idDeal=" + v_ids};
	parent.showObj(obj);
}


//删除 事件
function deleteData(){
	var v_ids = iframe.iframeObj["table"].getSelectedIds().join(",");
	var dealType = iframe.iframeObj["table"].getSelectedObjs("cooperativeAgencyDealStatus").join(",");
	var dealCodes = iframe.iframeObj["table"].getSelectedObjs("dealCode").join(",");
	//如果没有选中 数据则
	if(v_ids == ""){
		alert("请选择待删除的数据！");
		return;
	}
	
	var passage = dealType.indexOf('01');
	var complete = dealType.indexOf('02');
	
	if(!(complete>-1||passage>-1)){
		alert("只有新建或者在途才能删除！");
		return;
	}
	if(confirm("您确认要删除选择的数据吗？")){
        $.ajax({
            type:"POST",
            dataType : "json",
            url:contextRootPath+"/transfereeSettle/deleteDeal?dealCodes="+dealCodes,
            success:function(msg){
            	alert(msg.msg);
            	var v_status = msg.status;
            	//删除成功后
            	if(v_status.indexOf('ok') >-1){
            		iframe.iframeObj["table"].removeSelectedRow();
            	}
            	
            	
            }
        });
    }
}
/**
 * 查看受让交易信息
 * @param vId
 */
function viewData(vId){
	var dealCode = iframe.iframeObj["table"].dataMap[vId].dealCode;
	var cooperorgCode =iframe.iframeObj["table"].dataMap[vId].cooperorgCode;
	var contractCode = iframe.iframeObj["table"].dataMap[vId].contractCode;
	
	var cooperativeAgencyDealStatus = iframe.iframeObj["table"].getSelectedObjs("cooperativeAgencyDealStatus");
	var obj={"text":'修改受让赎回交易',"url":contextRootPath+'/transfereeSettle/prepareExecute/toBackTransfereeDealUpdate?contractCode=' + contractCode + "&dealCode=" + dealCode + "&cooperativeAgencyDealStatus=" + cooperativeAgencyDealStatus + "&cooperorgCode=" + cooperorgCode + "&idDeal=" + vId};
	parent.showObj(obj);
	
	/*var obj = {
		"text" : '查看受让赎回交易信息',
		"url" : contextRootPath + '/creditDealController/prepareExecute/toView?dealCode=' + dealCode +"&cooperorgCode="+cooperorgCode+"&contractCode="+contractCode
	};
	parent.showObj(obj);*/
	
}
